package com.dyh.quickdemo.demos.enhanceFuc;

import java.util.Objects;

/*
@Author=Joey Wheeler
@Date=2020/10/23 17:42
*/
public class FuncHelper {

//    ObjsFunc func = objects ->
    /*T1 t1,T2 t2,R r*/
   public  static  <T1,T2,R> ObjsFunc<R> trans(Func2<T1,T2,R> func2){
       return args->
           func2.invoke((T1)args[0],(T2)args[1]);
    }

    public static void main(String[] args) {
        Func2<String,String,Integer> func2= (s1,s2)->s1.length()+s2.length();
        Integer res = FuncHelper.trans(func2).invoke("hi","ffff",11);
        System.out.println(res);
    }

    /*
    new FuncN<R>() {

            @SuppressWarnings("unchecked")
            @Override
            public R call(Object... args) {
                if (args.length != 1) {
                    throw new IllegalArgumentException("Func1 expecting 1 argument.");
                }
                return f.call((T0) args[0]);
    */
}
